#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Run a short test simulation to verify everything is working.
This temporarily modifies the simulation time for quick testing.
"""

import sys
import os

# Add the project root to the Python path
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
if PROJECT_ROOT not in sys.path:
    sys.path.append(PROJECT_ROOT)

# Temporarily modify config before importing other modules
import config
original_sim_time = config.SIMULATION_TIME
original_output_freq = config.OUTPUT_FREQUENCY

# Set up for a short test: 2 flapping cycles
config.SIMULATION_TIME = 2.0 / config.FLAPPING_FREQUENCY  # 2 cycles
config.OUTPUT_FREQUENCY = 10  # Output every 10 steps

print("="*60)
print("Running SHORT TEST simulation")
print("="*60)
print(f"Original simulation time: {original_sim_time}s")
print(f"Test simulation time: {config.SIMULATION_TIME}s ({2} flapping cycles)")
print(f"This will run approximately {int(config.SIMULATION_TIME / config.TIME_STEP_SIZE)} time steps")
print("="*60)
print()

# Now import and run the main simulation
sys.path.append(PROJECT_ROOT)
from main import run_simulation

try:
    run_simulation()
    print("\n" + "="*60)
    print("✓ Short test simulation completed successfully!")
    print("  You can now run the full simulation with: python main.py")
    print("="*60)
except Exception as e:
    print("\n" + "="*60)
    print(f"✗ Test simulation failed with error: {e}")
    print("="*60)
finally:
    # Restore original config values
    config.SIMULATION_TIME = original_sim_time
    config.OUTPUT_FREQUENCY = original_output_freq 